package com.another.common.utils;


import com.another.common.utils.common.EmptyUtil;

import java.io.Serializable;
import java.math.BigInteger;


public class PageModel implements Serializable {

	private Integer page; // 页码
	private Integer start; // 起始位置
	private Integer length; // 每页记录数
	private BigInteger total; // 总记录数
	private Integer totalPages; // 总页数
	private String startDate;
	private String endDate;



    public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	public BigInteger getTotal() {
		return total;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public void setTotal(BigInteger total) {
    	if (!EmptyUtil.isEmpty(total)){
			if(page==null || page==0){
				page=1;
			}
			if (length == null || length.equals(0)) {
				length = 30;
			}
			this.totalPages = total.remainder(BigInteger.valueOf(length)).equals(BigInteger.ZERO)
					? total.divide(BigInteger.valueOf(length)).intValue()
					: total.divide(BigInteger.valueOf(length)).add(BigInteger.ONE).intValue();
			this.start = (page - 1) * length;
		}
		this.total = total;
	}

	public Integer getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(Integer totalPages) {
		this.totalPages = totalPages;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

}
